package test.pcs;

import com.google.gson.Gson;
import com.payment.lc.pcs.client.wrap.bo.ProductionALLAttributes;
import com.payment.lc.pcs.client.wrap.bo.ProductionLabelAttributes;
import com.payment.lc.pcs.client.wrap.service.ProductionWrapService;
import com.payment.lc.pcs.common.enums.BizType;
import com.payment.lc.pcs.common.enums.GroupType;
import com.payment.lc.pcs.rule.maintain.MaintainRuleService;
import com.payment.lc.pcs.service.api.AppSettingService;
import com.payment.lc.pcs.service.api.MaintainService;
import com.payment.lc.pcs.service.api.ProductionService;
import com.payment.lc.pcs.service.api.PushCommonService;
import com.payment.lc.pcs.service.domain.*;
import com.payment.lc.pcs.service.util.Common;
import com.payment.lc.pcs.service.util.PairObject;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import test.solution.Main;

import java.text.SimpleDateFormat;
import java.util.List;

/**
 * Created on 2016/8/8.
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:context-ws.xml")
public class PcsTest1 {

    Gson gson = new Gson();


    private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

    @Autowired
    MaintainService maintainRuleService;

    @Autowired
    ProductionService productionService;

    @Autowired
    ProductionWrapService productionWrapService;

    @Autowired
    AppSettingService appSettingService;

    @Test
    public void test() {
        test10();
    }

    void test16() {
        Bank icbc = productionWrapService.getBank("ICBC");
        System.out.println(gson.toJson(icbc));
    }
    void test15() {
        Production production = productionService.getProduction("KT90002");
        ProductionLabelAttributes prePurchase = productionWrapService.getLabelAttributes(production, "pre");
        System.out.println("gson.toJson(prePurchase) = " + gson.toJson(prePurchase));
    }

    void test14() {
        SystemConfig funds_basic_info = appSettingService.getSystemConfig("funds_basic_info");
        System.out.println("funds_basic_info = " + gson.toJson(funds_basic_info));
    }

    void test13() {
        Production production = productionService.getProduction("KT90002");
        ProductionALLAttributes productionALLAttributes = productionWrapService.getProductionALLAttributes(production);
        System.out.println("gson = " + gson.toJson(productionALLAttributes));
    }

    void test12() {
        ListWrapper<Production> dingqiListMore = productionService.getDisplayUpOrderedProductions(GroupType.MobileFrontPageGroup, "DingqiListMore");
        System.out.println("gson.toJson(sf2885) = " + gson.toJson(dingqiListMore));
    }

    void test11() {
        String name = "new_index_config";
        SystemConfig systemConfig = appSettingService.getSystemConfig(name);
        System.out.println(gson.toJson(systemConfig));
    }

    void test10() {
        Production sf2886 = productionService.getProduction("PT1");
        Object pt1 = productionService.getInsurance("PT1");
        System.out.println("gson.toJson(sf2886) = " + gson.toJson(sf2886));
        System.out.println("gson.toJson(pt1) = " + gson.toJson(pt1));
    }

    void test9() {
        maintainRuleService.getProductionMaintainInfoWrapper("SF2886");
    }

    void test8() {

        ListWrapper list = productionService.getBizs("SF2886");

        System.out.println("gson.toJson(list) = " + gson.toJson(list));

        Production production = productionService.getProduction("SF2886");
        System.out.println("gson = " + gson.toJson(production));

        List<ProductionDynamicInfo> dynamicInfoList = production.getDynamicInfoList();
        System.out.println("dynamicInfoList = " + gson.toJson(dynamicInfoList));

        ProductionDynamicInfo currentDynamicInfo = production.getCurrentDynamicInfo();
        System.out.println("currentDynamicInfo = " + gson.toJson(currentDynamicInfo));
    }

    void test7() {
        ListWrapper<ProductionLimit> limit = productionService.getLimit("SF2885", BizType.Fundin);
        System.out.println("gson.toJson(limit) = " + gson.toJson(limit));
        ProductionLimit productionLimit = limit.getList().get(0);
        System.out.println("gson.toJson(productionLimit) = " + gson.toJson(productionLimit));
        System.out.println("gson.toJson(productionLimit.getLimitFrames()) = " + gson.toJson(productionLimit.getLimitFrames()));
        List<ProductionLimitFrame> currentLimitFrames = productionLimit.getCurrentLimitFrames();
        System.out.println("gson.toJson(currentLimitFrames) = " + gson.toJson(currentLimitFrames));
    }

    public void print(Object object) {
        System.out.println("value = " + gson.toJson(object));
    }

    @Before
    public void before() {
        System.out.println("--------------------------");
        System.out.println("--------------------------");
    }

    @After
    public void after() {
        System.out.println("--------------------------");
        System.out.println("--------------------------");
    }
}
